﻿using Inovout.Locations;
using Inovout.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Inovout.Kuajing.Models
{
    public partial class Commodity : DataObject
    {
        private string code;
        /// <summary>
        /// 商品条码，对应网仓product_no
        /// 商品条码=商品编码+规格编码，也可称为料号
        /// </summary>
        public virtual string Code
        {
            get
            {
                if (string.IsNullOrEmpty(code))
                {
                    return  CategoryCode + FeatureCode;
                }
                //if (!code.Equals(CategoryCode + FeatureCode))
                //{
                //    throw new Exception("Code!=CategoryCode+featureCode");
                //}
                return code;
            }
            set
            {
                code = value;
            }
        }

        /// <summary>
        /// 商品类目编码
        /// </summary>
        public virtual string CategoryCode { get; set; }
        /// <summary>
        /// 特性编码，比如：颜色+尺码组合成一个编码
        /// </summary>
        public virtual string FeatureCode { get; set; }

        public virtual string FeatureName { get; set; }
        /// <summary>
        /// 货主标识，对应网仓sellerUserid
        /// </summary>
        public virtual string ExternalShipperId { get; set; }

        /// <summary>
        /// 海关备案价
        /// </summary>
        public virtual float Price { get; set; }
        public virtual string MeasurementUnit { get; set; }
        public virtual string Name { get; set; }
        public virtual string Title { get; set; }
        public virtual string Attributes { get; set; }
        public virtual string Remarks { get; set; }
        public virtual string StoreCode { get; set; }
        public virtual int Stock { get; set; }

        public virtual Warehouse Warehouse { get; set; }

        /// <summary>
        /// 供货价
        /// </summary>
        public virtual float OrginalPrice { get; set; }

        /// <summary>
        /// 建议最高零售价
        /// </summary>
        public virtual float MaxRetailPrice { get; set; }

        /// <summary>
        /// 建议最低零售价
        /// </summary>
        public virtual float MinRetailPrice { get; set; }

        /// <summary>
        /// 料号 
        /// </summary>
        public virtual string ExternalCode { get; set; }
        public virtual Brand Brand { get; set; }

        /// <summary>
        /// 生产国
        /// </summary>
        public virtual Location Location { get; set; }

        /// <summary>
        /// 行邮税分类
        /// </summary>
        public virtual string PostTaxesCategoryCode { get; set; }

        /// <summary>
        /// 运费模板
        /// </summary>
        public virtual ShippingTemplate ShippingTemplate { get; set; }


        public virtual object GetValue(string name)
        {
            return this.GetType().GetProperty(name).GetValue(this, null);
        }
    }
}
